package com.zf.mo.greater;

import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;

public class GreaterThan<T extends Number> extends BaseMatcher<T> {

    private final T value;

    public GreaterThan(T value) {
        this.value = value;
    }

    @Override
    public boolean matches(Object actual) {
        Class<?> clazz = actual.getClass();
        if(clazz == Integer.class){
            return (Integer)actual > (Integer)value;
        }
        if(clazz == Double.class){
            return (Double)actual > (Double)value;
        }

        return false;
    }
    public static <T extends Number> GreaterThan<T> gt(T value){
        return new GreaterThan(value);
    }

    @Override
    public void describeTo(Description description) {
        description.appendText("compare two number Failed");
    }
}
